<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
</head>
<body onload="draw()">

<div id="container">
    <canvas id="mycanvas">Your Browser does not support Canvas, please upgrade</canvas>
</div>

<script>
    // 综合应用，平移、旋转、缩放
    function draw() {
        const canvas = document.getElementById('mycanvas');
        const ctx = canvas.getContext('2d');
        // 设置canvas元素的宽高以及变宽的样式
        canvas.setAttribute("width", 150);
        canvas.setAttribute("height", 150);
        canvas.style.border = '1px solid red';
        // 将原点平移
        ctx.translate(50, 50);
        // 将原点旋转
        ctx.rotate(Math.PI / 6);
        // 将图形进行缩放
        ctx.scale(0.25, 0.5);
        // 开始绘制图像
        ctx.fillRect(0, 0, 50, 50);
    }
</script>
</body>
</html>